-
Notifications
You must be signed in to change notification settings - Fork 9
Support vulkan backend #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Support vulkan backend #110
Conversation
|
@JSUYA Do you konw how to fix unittests build error? |
I will look into it. |
|
+) #113 |
@xiaowei-guan |
1.Fix spelling issues. 2.Do not need to destroy swapchain image when destory the renderer. 3.Replace memset with zero-init. 4.Free command buffer when begin command buffer or end command buffer failed. 5.Fix return wrong api version issue.
The problem was solved with the help of @swift-kim. |
@JSUYA Yes, if we want to run vulkan app on RPI4, we need to install vulkan related rpm files. @swift-kim @JSUYA Thank you, the issue has been fixed. |
|
@JSUYA Can you review the code? |
|
@xiaowei-guan On TV, it failed to create a vk instance. And since libvulkan is not included in the binary by default, merging vulkan PRs for the embedder and engine will prevent Flutter apps from running in the basic Common Headed Profile. |
|
|
||
| std::unique_ptr<ExternalTexture> TizenRendererVulkan::CreateExternalTexture( | ||
| const FlutterDesktopTextureInfo* texture_info) { | ||
| return nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question
External texture is not supported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have finished code of External texture:
- Engine PR : [Tizen] Support render texture for vulkan + impeller flutter#17
- Embedder code : xiaowei-guan@6a94746
After vulkan backend PR released, I will create a new PR for texture.
0d078ae to
6f7c767
Compare
In tizen repo, the vulkan so files are uploaded, but they are not actually included in the image binary. Therefore, unless user install the RPI binary and separately install libvulkan, user cannot run a Flutter app even if they do not use the EVulkan renderer. How about additionally releasing libflutter_tizen.so that supports the Vulkan renderer? For example... The flutter-tizen tool can download experimental artifacts to the cache and load experimental SO files using predefined settings or separate flags. (Ex flutter-tizen run --dart-define=USE_FLUTTER_TIZEN_EXPERIMENTAL ?) please suggest better approaches if you have them. |
result is VK_SUBOPTIMAL_KHR or VK_ERROR_OUT_OF_DATE_KHR.
As I konw, all tizen device profile has included vulkan, but the
Ok |
Add new struct FlutterVulkanTexture for embedder :
```
typedef struct {
/// Handle to the VkImage that is owned by the embedder. The engine will
/// bind this image for writing the frame.
FlutterVulkanImageHandle image;
/// The VkDeviceMemory that backs the iamge.
FlutterVulkanDeviceMemoryHandle image_memory;
/// The VkFormat of the image (for example: VK_FORMAT_R8G8B8A8_UNORM).
uint32_t format;
/// User data to be returned on the invocation of the destruction callback.
void* user_data;
/// Callback invoked (on an engine managed thread) that asks the embedder to
/// collect the texture.
VoidCallback destruction_callback;
/// Optional parameters for texture height/width, default is 0, non-zero means
/// the texture has the specified width/height.
/// Width of the texture.
size_t width;
/// Height of the texture.
size_t height;
} FlutterVulkanTexture;
```
The implement of [texture
source](https://github.com/flutter-tizen/flutter/pull/17/files#diff-7955a8522a753162869f2e8ca0017a83f4854b60800c844202e70c3aa00ff0c9R5-R204)
refer to the solution of android
platform(https://github.com/flutter-tizen/flutter/blob/flutter-3.35.3/engine/src/flutter/impeller/renderer/backend/vulkan/android/ahb_texture_source_vk.cc)
and I have submitted the code [Support render texture for
embedder](xiaowei-guan/embedder@6a94746),
I will create a new PR after[ support vulkan
backend](flutter-tizen/embedder#110) PR
released.
| embedder("flutter_tizen_common_experimental") { | ||
| target_type = "shared_library" | ||
|
|
||
| defines = [ "COMMON_PROFILE" ] | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to test libflutter_tizen_common_experimental.so on an RPi4 with the Vulkan library installed.
I renamed libflutter_tizen_common_experimental.so to libflutter_tizen_common.so in the path flutter/bin/cache/artifacts/engine/tizen-arm/6.5.
c# hostapp ran the Vulkan renderer app normally.
However, c++ hostapp displayed the error message below. Do you know the cause?
E/STDERR_pkgmgr-server( 8385): [EXEC_CHECKER_PLUGIN_PARSER][ERROR] Not found library ( libflutter_tizen_common_experimental.so)
E/STDERR ( 8112): /opt/usr/globalapps/com.example.test_cpp_6/bin/runner: error while loading shared libraries: libflutter_tizen_common_experimental.so: cannot open shared object file: No such file or directory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, I can't reproduce this issue:
below are my steps:
2025 cp ../embedder/src/out/tizen_arm_6.5/libflutter_tizen_common_experimental.so ../flutter-tizen/flutter/bin/cache/artifacts/engine/tizen-arm/6.5/libflutter_tizen_common.so
2026 sync
2027 ../flutter-tizen/bin/flutter-tizen clean
2028 ../flutter-tizen/bin/flutter-tizen run --enable-impeller
and logs:
guanxw@samsung10022:~/flutter-tizen-3.35.3/sample$ ../flutter-tizen/bin/flutter-tizen run --enable-impeller
Launching tizen/flutter/generated_main.dart on Tizen rpi4 in debug mode...
The partner profile is used for signing.
Building a Tizen application in debug mode... 24.3s
✓ Built build/tizen/tpk/com.example.sample-1.0.0.tpk (30.1MB)
Installing build/tizen/tpk/com.example.sample-1.0.0.tpk... 19.4s
[E] [WARNING:flutter/impeller/renderer/backend/vulkan/driver_info_vk.cc(263)] Unknown GPU Driver Vendor: 5348. This is not an error.
[IMPORTANT:flutter/shell/platform/embedder/embedder_surface_vulkan_impeller.cc(80)] Using the Impeller rendering backend (Vulkan).
Syncing files to device Tizen rpi4... 57ms
Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
h List all available interactive commands.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).
A Dart VM Service on Tizen rpi4 is available at: http://127.0.0.1:43323/LoQ0Sh-iQZs=/
The Flutter DevTools debugger and profiler on Tizen rpi4 is available at: http://127.0.0.1:9101?uri=http://127.0.0.1:43323/LoQ0Sh-iQZs=/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the confirmation, but just looking at your logs I can't tell if it's a C# app or a C++ app.
I tried setting up RPI5+ aarch64 environment again and it still fails with c++ host app (--tizen-language=cpp).
(In the log it shows as rpi4 due to the fusing script.)
E/STDERR_pkgmgr-server( 5433): [EXEC_CHECKER_PLUGIN_PARSER][ERROR] Not found library ( libflutter_tizen_common_experimental.so)
E/STDERR ( 5281): /opt/usr/globalapps/com.example.test_cpp_6/bin/runner: error while loading shared libraries: libflutter_tizen_common_experimental.so: cannot open shared object file: No such file or directory
I don't want to delay progress on this PR any longer. Since you have separated the feature into experimental so, it won't affect existing behavior.
Therefore, I think it's okay to continue monitoring this PR after it's merged.
So.. It needs to be synchronized with the Interop.cs of flutter-tizen. Please also prepare the flutter-tizen patch.
(The flag to use experimental.so can be prepared as a separate PR.)
If your C++ host app tests ok, please merge this patch.
Below is the log of my test.
Changed libflutter_tizen_common to libflutter_tizen_common_experimental.so
~/dev/os/f-project/flutter-tizen/flutter/bin/cache/artifacts/engine/tizen-arm64/6.5 ((HEAD detached at FETCH_HEAD)) 14:59:33 $ cp libflutter_tizen_common_experimental.so ./libflutter_tizen_common.so
C++ host app test
$ flutter-tizen create test_cpp_7 --tizen-language=cpp
Creating project test_cpp_7...
Resolving dependencies in `test_cpp_7`...
Downloading packages...
Got dependencies in `test_cpp_7`.
Wrote 137 files.
All done!
You can find general documentation for Flutter at: https://docs.flutter.dev/
Detailed API documentation is available at: https://api.flutter.dev/
If you prefer video documentation, consider: https://www.youtube.com/c/flutterdev
In order to run your application, type:
$ cd test_cpp_7
$ flutter run
Your application code is in test_cpp_7/lib/main.dart.
~/dev/os/f-project/dev 15:11:05 $ cd test_cpp_7/
~/dev/os/f-project/dev/test_cpp_7 15:11:10 $ vi tizen/tizen-manifest.xml //modify api-version 6.0 to 6.5
~/dev/os/f-project/dev/test_cpp_7 15:11:32 $ flutter-tizen run --enable-impeller
Connected devices:
Linux (desktop) • linux • linux-x64 • Ubuntu 22.04.5 LTS 6.8.0-87-generic
Chrome (web) • chrome • web-javascript • Google Chrome 142.0.7444.59
Tizen rpi4 (mobile) • d633f6d91e953c01 • flutter-tester • Tizen 10.0
[1]: Linux (linux)
[2]: Chrome (chrome)
[3]: Tizen rpi4 (d633f6d91e953c01)
Please choose one (or "q" to quit): 3
Launching tizen/flutter/generated_main.dart on Tizen rpi4 in debug mode...
The platform profile is used for signing.
Building a Tizen application in debug mode... ⡿
17.4s
✓ Built build/tizen/tpk/com.example.test_cpp_7-1.0.0.tpk (31.3MB)
Installing build/tizen/tpk/com.example.test_cpp_7-1.0.0.tpk... 7.9s
dlogutil STDERR
E/STDERR (17113): /opt/usr/globalapps/com.example.test_cpp_7/bin/runner: error while loading shared libraries: libflutter_tizen_common_experimental.so: cannot open shared object file: No such file or directory
C# host app test
$ flutter-tizen create test_27
Creating project test_27...
Resolving dependencies in `test_27`...
Downloading packages...
Got dependencies in `test_27`.
Wrote 135 files.
All done!
You can find general documentation for Flutter at: https://docs.flutter.dev/
Detailed API documentation is available at: https://api.flutter.dev/
If you prefer video documentation, consider: https://www.youtube.com/c/flutterdev
In order to run your application, type:
$ cd test_27
$ flutter run
Your application code is in test_27/lib/main.dart.
~/dev/os/f-project/dev 15:15:02 $ cd test_27/
~/dev/os/f-project/dev/test_27 15:15:05 $ vi tizen/tizen-manifest.xml //modify api-version 6.0 to 6.5
$ flutter-tizen run --enable-impeller
Connected devices:
Linux (desktop) • linux • linux-x64 • Ubuntu 22.04.5 LTS 6.8.0-87-generic
Chrome (web) • chrome • web-javascript • Google Chrome 142.0.7444.59
Tizen rpi4 (mobile) • d633f6d91e953c01 • flutter-tester • Tizen 10.0
[1]: Linux (linux)
[2]: Chrome (chrome)
[3]: Tizen rpi4 (d633f6d91e953c01)
Please choose one (or "q" to quit): 3
Launching tizen/flutter/generated_main.dart on Tizen rpi4 in debug mode...
Building a Tizen application in debug mode... ⣿
The platform profile is used for signing.
Building a Tizen application in debug mode... 13.9s
✓ Built build/tizen/tpk/com.example.test_27-1.0.0.tpk (31.4MB)
Installing build/tizen/tpk/com.example.test_27-1.0.0.tpk... 9.8s
[E] flutter_tizen_engine.cc: SetView(299) > renderer_type : 0
[E] [IMPORTANT:flutter/shell/platform/embedder/embedder_surface_gl_impeller.cc(99)] Using the Impeller rendering backend (OpenGL).
Syncing files to device Tizen rpi4... 58ms
Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
h List all available interactive commands.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).
A Dart VM Service on Tizen rpi4 is available at: http://127.0.0.1:45779/S7ddlTj023c=/
The Flutter DevTools debugger and profiler on Tizen rpi4 is available at: http://127.0.0.1:9105?uri=http://127.0.0.1:45779/S7ddlTj023c=/
|
@JSUYA Hello, sorry my mistake. I can reproduce this issue with C++ app.
|
There is a way to change the SONAME directly using patchelf. I think you can change the SONAME before uploading experimental.so in embedder's upload-artifact. before after I have checked that this works fine in a C++ app. |
Great, now it works fine. |
Because vulkan libs are not included in the binary by default. we need to install vulkan libs before run vulkan app on device.
How to set vulkan for Tizen device:
RPI4 hreaded image already has vulkan driver, no need to install to the target.
For TV image, you need to install vulkan driver manually to the target.
vulkan-loader
vulkan-tools
vulkan-wsi-layer
rpm -Uvh --force --nodeps *.rpm
vulkaninfo or vkcube
I can run vulkan backend app on RPI4.
Because the vulkan driver on TV is not stable, I can only run vulkan backend app on Tizen 8.0 with old version dirver.